Visual Basic  VBS еĺʵֵ.

ãڶԻʾϢȴûťһ Integer ûһť

﷨

MsgBox(prompt[, buttons] [, title] [, helpfile, context])

˵

MsgBox ﷨¼

Prompt-------ġַʽΪʾڶԻеϢprompt 󳤶ȴԼΪ 1024 ַַĿȾ prompt ݳһУÿһ֮ûس (Chr(13))з (Chr(10)) ǻس뻻з (Chr(13) & Chr(10)) зָ

Buttons-------ѡġֵʽֵָܺͣʾťĿʽʹõͼʽȱʡťʲôԼϢǿƻӦȡʡԣ buttons ȱʡֵΪ 0

Title-------ѡġڶԻʾַʽʡ titleӦóڱС

Helpfile--------ѡġַʽʶԻṩذİļṩ helpfileҲṩ context

Context-------ѡġֵʽɰļָʵİİıšṩ contextҲṩ helpfile

MsgBoxButtonsĳ

ֵ ˵

vbOKOnly 0 ֻʾȷťȱʡֵ

VbOKCancel 1 ʾȷ͡ȡť

VbAbortRetryIgnore 2 ʾֹԡ͡ԡ ť

VbYesNoCancel 3 ʾǡ񡱺͡ȡť

VbYesNo 4 ʾǡ͡񡱰ť

VbRetryCancel 5 ʾԡ͡ȡť

VbCritical 16 ʾؼϢͼ

VbQuestion 32 ʾѯʡͼ

VbExclamation 48 ʾϢͼ

VbInformation 64 ʾ֪ͨϢͼ

vbDefaultButton1 0 һťȱʡֵ(ȱʡ)

vbDefaultButton2 256 ڶťȱʡֵ

vbDefaultButton3 512 ťȱʡֵ

vbDefaultButton4 768 ĸťȱʡֵ

vbApplicationModal 0 ӦóǿƷأӦóһֱֱûϢ

Ӧż

vbSystemModal 4096 ϵͳǿƷأȫӦó򶼱ֱûϢ

Ӧż

vbMsgBoxHelpButt 16384 HelpťӵϢ

on

VbMsgBoxSetFore 65536 ָϢ򴰿Ϊǰ

ground

vbMsgBoxRight 524288 ıΪҶ

vbMsgBoxRtlRe 1048576 ָıӦΪϣͰϵͳеĴҵʾ

ading

˵

(1)һֵ(0C5)ϢʾİťĿڶֵ(16,32,48,64)ͼʽֵ(0,256,512,768)˵һťȱʡֵֵ(0,4096)ϢǿƷԡЩButtonsֵʱֻÿֵȡһ֡

(2)Щ Visual Basic for Applications (VBA) ָġڳеʹЩƣʹʵֵʵֵ볣ǵȼ۵ġ

ֵ

MsgBoxֵĳ

ֵ ˵

vbOK 1 ȷ

vbCancel 2 ȡ

vbAbort 3 ֹ

vbRetry 4 

vbIgnore 5 

vbYes 6 

vbNo 7 

(1) ͬʱṩHelpfileContext԰F1鿴ContextӦİ⣬ExcelͨԶһ(Help)ť

(2)ϢʾȡťESC뵥ȡťЧͬϢСťṩصİϢ

(3)ҪʡмĳЩӦλü붺ŷֽ

ʾ

(1)(1)ʹ MsgBox ھСǡ񡱰ťĶԻʾһشϢʾеȱʡťΪ񡱣MsgBoxķֵûһťDEMO.HLPΪһļһΪ1000

Dim Msg,Style,Title,Help,Ctxt,Response,MyString

Msg="Do you want to continue ?" Ϣı

Style = vbYesNo + vbCritical + vbDefaultButton2 ' 尴ť

Title = "MsgBox Demonstration" ' ı

Help = "DEMO.HLP" ' ļ

Ctxt = 1000 ' 

Response = MsgBox(Msg, Style, Title, Help, Ctxt)

If Response = vbYes Then ' û¡ǡ

MyString = "Yes" ' ĳ

Else ' û¡

MyString = "No" ' ĳ

End If

(2)ֻʾĳϢ

MsgBox Hello!

(3)Ϣ򷵻صĽֵ

Ans=MsgBox(Continue?,vbYesNo)

If MsgBox(Continue?,vbYesNo)<>vbYes Then Exit Sub

(4)ʹóϣֵConfigõڶťΪȱʡť

Config=vbYesNo+vbQuestion+vbDefaultButton2

(5)ҪϢǿƻУıʹvbCrLf(vbNewLine)&+ӿոַ

MsgBox This is the first line. & vbNewLine & Second line.

(6)ϢʹvbTabһƱĹʹһϢʾ55ԪеֵvbTabָвʹvbCrLfһСעMsgBoxֻʾ1024ַ˿ʾĵԪ

Option Explicit

Sub ShowRangeValue()

Dim Msg As String

Dim r As Integer, c As Integer

Msg = ""

For r = 1 To 5

For c = 1 To 5

Msg = Msg & Cells(r, c) & vbTab

Next c

Msg = Msg & vbCrLf

Next r

MsgBox Msg

End Sub

(7)ϢùԼʾøʽʾ

MsgBox " selection has " & m & " cells ." & Chr(13) & " the sum is :" & Application.WorksheetFunction.Sum(Selection) & Chr(13) & "the average is :" & Format(Application.WorksheetFunction.Average(Selection), "#,##0.00"), vbInformation, "selection count & sum & average" & Chr(13)



private sub form_load() '¼

msgbox("") '趨

end sub '

ͼƬеĴ룺 MsgBox "!", 26, "!"
